%%
psnrList = cell(50, 1);
for k = 1 : 2
    line = 0;
    fid = fopen('PSNR_SSIM.txt');
    while true
        tline = fgetl(fid);
        if ~ischar(tline), break; end
        
        line = line + 1;
        psnrList{line} = extractPSNRFromTxt(strtrim(tline), k);
    end
    psnrList = psnrList(1 : line);
    fclose(fid);
    
    if k == 1
        psnrMat = cell2mat(psnrList)';
        psnrMat(:, [4 : 4 : end, 5 : 4 : end]) = [];
    elseif k == 2
        ssimMat = cell2mat(psnrList)';
        ssimMat(:, [4 : 4 : end, 5 : 4 : end]) = [];
    end
end

%%
clc
SetList = {'Set5', 'Set14', 'B100', 'Urban100'};
si = 0;
scale = 1;
for i = 1 : size(psnrMat, 1)
    s0 = '';
    if rem(i, 3) == 1
        si = si + 1;
        s0 = sprintf('\\hline \\hline \n \\multirow{3}{*}{%s}', SetList{si});
    end
    
    scale = scale + 1;
    if scale > 4
        scale = 2;
    end
    
    s = '';
    for j = 1 : size(psnrMat, 2)
        s = sprintf('%s%.2f/%.3f & ', s, psnrMat(i, j), ssimMat(i, j));
    end
    s(end-2 : end) = [];
    
    fprintf('%s & \\texttimes %g & %s\\\\\n', s0, scale, s);
end
